package com.liujiaqi.lease.web.app.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.liujiaqi.lease.model.entity.LeaseTerm;
import com.liujiaqi.lease.model.entity.RoomInfo;
import com.liujiaqi.lease.model.enums.ItemType;
import com.liujiaqi.lease.web.app.mapper.GraphInfoMapper;
import com.liujiaqi.lease.web.app.mapper.LeaseTermMapper;
import com.liujiaqi.lease.web.app.mapper.RoomInfoMapper;
import com.liujiaqi.lease.web.app.service.RoomInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liujiaqi.lease.web.app.vo.graph.GraphVo;
import com.liujiaqi.lease.web.app.vo.room.RoomDetailVo;
import com.liujiaqi.lease.web.app.vo.room.RoomItemVo;
import com.liujiaqi.lease.web.app.vo.room.RoomQueryVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author liubo
 * @description 针对表【room_info(房间信息表)】的数据库操作Service实现
 * @createDate 2023-07-26 11:12:39
 */
@Service
@Slf4j
public class RoomInfoServiceImpl extends ServiceImpl<RoomInfoMapper, RoomInfo>
        implements RoomInfoService {

  @Autowired
  RoomInfoMapper roomInfoMapper;

  @Autowired
  GraphInfoMapper graphInfoMapper;

  @Autowired
  LeaseTermMapper leaseTermMapper;

  @Override
  public IPage<RoomItemVo> pageItem(Page<RoomItemVo> page, RoomQueryVo queryVo) {
    return roomInfoMapper.pageItem(page, queryVo);
  }

  @Override
  public RoomDetailVo getDetailById(Long id) {
    // 1.查找房间信息
    RoomInfo roomInfo = roomInfoMapper.selectById(id);

    if (roomInfo == null) {
      return null;
    }

    // 2.查询图片
    List<GraphVo> graphVoList = graphInfoMapper.selectListByItemTypeAndId(ItemType.ROOM, id);

    // 3.查询租期
    List<LeaseTerm> leaseTermList = leaseTermMapper.selectListByRoomId(id);

    // 4.查询配套
    return null;
  }
}




